-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
REF: prepare dataframe info for series info #37868
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
pandas/io/formats/info.py
Outdated
def ids(self) -> Index: | ||
"""Column names or index names.""" | ||
def dtypes(self) -> Iterable[Dtype]: | ||
"""Dtypes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
newline after triple-quote
if there's nothing useful to write, leave it blank
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks fine.
pandas/io/formats/info.py
Outdated
|
||
Parameters | ||
---------- | ||
data : FrameOrSeries | ||
data : FrameOrSeriesUnion |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@simonjayhawkins is this right here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The variable type annotation for data
is correct if this doesn't need to be a Generic class.
FrameOrSeries is a typevar and using a typevar for a variable type annotation gives error: Type variable "pandas._typing.FrameOrSeries" is unbound [valid-type]
However, for the docstring, I think it is still preferred not to use Type notation, even for internal docstrings and follow the documentation contributing guide.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @ivanovmg. lgtm. one comment (can be done in the follow-up)
@abstractmethod | ||
def ids(self) -> Index: | ||
"""Column names or index names.""" | ||
def dtypes(self) -> Iterable[Dtype]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@abstractmethod
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I guess abstractmethod
should be there.
Fixed.
Got some irrelevant error in CI Check.
|
fixed on master |
): | ||
self.data = data | ||
self.memory_usage = _initialize_memory_usage(memory_usage) | ||
data: FrameOrSeriesUnion |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are we using FrameOrSeries? cc @simonjayhawkins
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see #37868 (comment)
@@ -2523,16 +2523,25 @@ def to_html( | |||
@Substitution( | |||
klass="DataFrame", | |||
type_sub=" and columns", | |||
max_cols_sub=( | |||
"""max_cols : int, optional | |||
max_cols_sub=dedent( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you do a followup where you switch to using @doc
before the Series.info change
black pandas
git diff upstream/master -u -- "*.py" | flake8 --diff
Precursor for #37320
Refactor
pandas/io/formats/info.py
to simplify further introduction ofSeries.info
.Basically what is done here:
BaseInfo
fromDataFrameInfo
- supposedly will be shared withSeriesInfo
col_count
,ids
fromBaseInfo
toDataFrameInfo
(will not be relevant toSeriesInfo
)memory_usage_bytes
toDataFrameInfo
(will have different implementation forSeriesInfo
)InfoPrinterAbstract
. Concrete classes will differ by the_create_table_builder
DataFrameTableBuilder
toTableBuilderAbstract
TableBuilderVerboseMixin
fromDataFrameTableBuilderVerbose
as the generator functions there will be used for verbose series info buildersI suggest moving the substitution decorator for the docstring from
pandas/core/frame.py
topandas/io/formats/info.py
later on in a separate PR.